package com.yy.jhl.app;

import com.baidu.mapapi.SDKInitializer;
import com.yy.common.baseapp.BaseApplication;
import com.yy.common.commonutils.LogUtils;
import com.yy.common.commonutils.SPUtils;
import com.yy.jhl.util.greendao.ExceptionDaoUtils;
import com.tencent.bugly.crashreport.CrashReport;

/**
 * Created by Ellis.Li on 2017/5/8.
 */

public class MyApplication extends BaseApplication {
    private static MyApplication instance;
    public static MyApplication getInstance() {
        return instance;
    }
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        //初始化bugly
        CrashReport.initCrashReport(getApplicationContext(), "5f8385d726", true);
        //初始化logger
        LogUtils.logInit(true);
        // 在使用 SDK 各组间之前初始化 context 信息，传入 ApplicationContext
        SDKInitializer.initialize(this);
    }

    /**
     * 清空缓存(sqlite sp)数据
     */
    public void clearData(){
        String userName = SPUtils.getSharedStringData(instance,AppConstant.SP_KEY_USER_NAME);
        String pwd = SPUtils.getSharedStringData(instance,AppConstant.SP_KEY_USER_PWD);
        int loginType = SPUtils.getSharedIntData(instance, AppConstant.SP_KEY_LOGIN_TYPE);
        SPUtils.clear(instance);
        SPUtils.setSharedStringData(instance, AppConstant.SP_KEY_USER_NAME, userName);
        SPUtils.setSharedStringData(instance, AppConstant.SP_KEY_USER_PWD, pwd);
        SPUtils.setSharedIntData(instance, AppConstant.SP_KEY_LOGIN_TYPE, loginType);
//        ExceptionDaoUtils.getInstance(instance).deleteAll();
    }
}
